package org.groupg.practice.Processor;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

public class RxJavaMain {
    public static void main(String[] args) throws InterruptedException {
        RxJavaIndicatorProcessor processor = new RxJavaIndicatorProcessor();

        // 模拟多个生产者线程
        int producerCount = 10;
        ExecutorService executor = Executors.newFixedThreadPool(producerCount);

        // 模拟1000个指标
        for (int i = 0; i < 1000; i++) {
            final int index = i;
            executor.submit(() -> {
                String name = "Indicator-" + index;
                Object data = "Data-" + index;
                processor.publishIndicator(name, data);
            });
        }

        // 等待处理完成
        executor.shutdown();
        executor.awaitTermination(1, TimeUnit.MINUTES);

        Thread.sleep(2000); // 给消费者时间处理
        processor.shutdown();
    }
}